import Vue from 'vue';
import VeeValidate from 'vee-validate';
import zh_CN from 'vee-validate/dist/locale/zh_CN'

Vue.use((VeeValidate));

// 表单验证
VeeValidate.Validator.localize('zh_CN', {
    messages: {
        ...zh_CN.messages,
        is: (field) => `${field}必须与密码相同` //修改内置规则的message，让确认密码和密码相同  
    },
    attributes: {
        username: '用户名',
        phone: '手机号',
        sex: '性别',
        password: '密码',
        password1: '确认密码',
        addcount: '金额',
        card: '卡号',
        cardPass: '卡号密码'
    }
})

// 自定义校验规则
VeeValidate.Validator.extend("agree", {
    validate: (value) => {
        return value
    },
    getMessage: (field) => field + "请勾选用户协议"
})

VeeValidate.Validator.extend("addcount", {
    validate: (value) => {
        return value
    },
    getMessage: (field) => field + "请输入正确格式"
})

VeeValidate.Validator.extend("card", {
    validate: (value) => {
        return value
    },
    getMessage: (field) => field + "请输入卡号"
})

VeeValidate.Validator.extend("cardPass", {
    validate: (value) => {
        return value
    },
    getMessage: (field) => field + "请输入6位卡号密码"
})